
import UIKit
import SnapKit


class AssistantCell : UICollectionViewCell{
    var assistant: Assistant!
    func bindViewModel(_ assistant: Assistant) {
        avatarImageView.kf.setImage(with: URL(string: assistant.cover))
        numbersleLabel.text = assistant.users
        nameLabel.text = assistant.title
        subtitleLabel.text = assistant.subTitle
    }
    
    
    var avatarImageView: UIImageView = {
        let cover = UIImageView()
        cover.layer.cornerRadius = 16
        cover.contentMode = UIView.ContentMode.scaleAspectFill
        cover.clipsToBounds = true
        cover.isUserInteractionEnabled = true
        return cover
    }()
    
    
    var nameLabel: UILabel = {
        let titelLabel = UILabel()
        titelLabel.font = UIFont.systemFont(ofSize: 16, weight: .medium)
        titelLabel.textColor = .black
        titelLabel.text = "学习顾问"
        titelLabel.numberOfLines = 1
        return titelLabel
    }()
    
    var numbersleLabel: UILabel = {
        let titelLabel = UILabel()
        titelLabel.font = UIFont.systemFont(ofSize: 12)
        titelLabel.textColor = .gray
        titelLabel.numberOfLines = 1
        
        
        return titelLabel
    }()
    
    var subtitleLabel: UILabel = {
        let titelLabel = UILabel()
        titelLabel.font = UIFont.systemFont(ofSize: 13,weight: .regular)
        titelLabel.textColor = .gray
        titelLabel.numberOfLines = 1
        
        
        return titelLabel
    }()
    
    
  
    
    
  
    
    override init(frame: CGRect) {
        super.init(frame: .zero)
        self.addSubview(nameLabel)
        self.addSubview(subtitleLabel)
        self.addSubview(avatarImageView)
        self.addSubview(numbersleLabel)
        self.backgroundColor = UIColor(red: 244/255, green: 246/255, blue: 249/255, alpha: 1.0)
        self.layer.cornerRadius = 16
        
       
        
        
       
        avatarImageView.snp.makeConstraints { make in
            make.top.equalTo(self)
            make.left.equalTo(self)
            make.width.equalTo(self)
            make.height.equalTo(self.snp.width)
            
        }
        
        
        nameLabel.snp.makeConstraints { make in
            make.top.equalTo(avatarImageView.snp.bottom).offset(12)
            make.left.equalTo(self).offset(8)
            make.width.equalTo(self).offset(-16)
            
            
        }
        
        numbersleLabel.snp.makeConstraints { make in
            make.top.equalTo(nameLabel.snp.bottom).offset(6)
            make.left.equalTo(nameLabel)
            make.width.equalTo(self).offset(-16)
        }
        
        subtitleLabel.snp.makeConstraints { make in
            make.top.equalTo(numbersleLabel.snp.bottom).offset(6)
            make.left.equalTo(nameLabel)
            make.width.equalTo(self).offset(-16)
        }

    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

